package com.hrms.controller;

import com.hrms.common.AjaxResult;
import com.hrms.common.BaseController;
import com.hrms.domain.Evaluation;
import com.hrms.service.EvaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin/evaluation")
public class EvaluationController extends BaseController {
    @Autowired
    private EvaluationService evaluationService;

    // 查询评价列表
    @GetMapping("/list")
    public AjaxResult list(Evaluation evaluation){
        List<Evaluation> list = evaluationService.selectEvaluationList(evaluation);
        return success(list);
    }

    //获取评价详细信息
    @GetMapping(value = "/{evaluationId}")
    public AjaxResult getInfo(@PathVariable("evaluationId") Long evaluationId){
        return success(evaluationService.selectDepartmentByDeptNo(evaluationId));
    }

    //新增评价
    @PostMapping
    public AjaxResult add(@RequestBody Evaluation evaluation){
        evaluation.setEvaluationTime(new Date());
        return toAjax(evaluationService.insertDepartment(evaluation));
    }

    //修改评价
    @PutMapping
    public AjaxResult edit(@RequestBody Evaluation evaluation){
        evaluation.setEvaluationTime(new Date());
        return toAjax(evaluationService.updateDepartment(evaluation));
    }

    //删除评价
    @DeleteMapping("/{evaluationId}")
    public AjaxResult remove(@PathVariable Integer evaluationId){
        return toAjax(evaluationService.deleteDepartmentByDeptNos(evaluationId));
    }
}
